﻿using System;
using System.Linq.Expressions;

namespace K9Nano.Application
{
    public interface IPagedInputDto<TEntity>
    {
        int PageIndex { get; set; }
        int PageSize { get; set; }

        int Skip();
        Expression<Func<TEntity, bool>> Predicate();
        Expression<Func<TEntity, object>> OrderBy();
    }

    public class PagedInputDto<TEntity> : IPagedInputDto<TEntity>
    {
        public virtual int PageIndex { get; set; }
        public virtual int PageSize { get; set; }

        public virtual int Skip() => (PageIndex - 1) * PageSize;
        public virtual Expression<Func<TEntity, bool>> Predicate() => _ => true;
        public virtual Expression<Func<TEntity, object>> OrderBy() => _ => "Id";
    }
}